#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,n,m,l,V,d[100005],v[100005],a[100005],r[100005];
ll cnt,ans[107],sna[107];
map<int,int>vis[3007],k;
void init(){
    for(int i=1;i<=n;i++){
        k[i]=0;
        for(int j=1;j<=m;j++)vis[i][j]=0;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cnt++;
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>r[i];
        for(int i=1;i<=n;i++){
            int f=0;
            for(int j=1;j<=m;j++){
                if(d[i]>r[j]){
                    vis[i][j]=1;
                    continue;
                }
                ll e=v[i]*v[i]+2*a[i]*(r[j]-d[i]);
                if(e>V*V)f=1,k[i]++;
                else vis[i][j]=1;
            }
            ans[cnt]+=f;
        }
        for(int j=1;j<=m;j++){
            int f=0;
            for(int i=1;i<=n;i++){
                if(!vis[i][j]&&k[i]-1==0){
                    f=1;
                    break;
                }
            }
            if(!f){
                sna[cnt]++;
                for(int i=1;i<=n;i++){
                    if(!vis[i][j])k[i]--;
                }
            }
        }
        init();
    }
    for(int i=1;i<=cnt;i++)cout<<ans[i]<<" "<<sna[i]<<endl;
    return 0;
}
